<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="mysql," />





  <link rel="alternate" href="/atom.xml" title="耿瑞阳的博客" type="application/atom+xml" />






<meta name="description" content="前言公司线上使用阿里云的mysql数据库，一直是单点，也是系统中最大的瓶颈。因为开始考虑的是单点，所以第一个负责人将RDS的配置设置的很高，造成了特别大的资源浪费。平时cpu的内存的使用率都特别低。现在的负责人觉得RDS高配置很浪费，做了降配处理，春节前活动直接被查询宕机。所以现在需要考虑优化方案">
<meta name="keywords" content="mysql">
<meta property="og:type" content="article">
<meta property="og:title" content="虚拟机安装Centos，安装mysql，配置主从（一）">
<meta property="og:url" content="https://Gengry.github.io/2018/02/05/虚拟机安装Centos，安装mysql，配置主从（一）/index.html">
<meta property="og:site_name" content="耿瑞阳的博客">
<meta property="og:description" content="前言公司线上使用阿里云的mysql数据库，一直是单点，也是系统中最大的瓶颈。因为开始考虑的是单点，所以第一个负责人将RDS的配置设置的很高，造成了特别大的资源浪费。平时cpu的内存的使用率都特别低。现在的负责人觉得RDS高配置很浪费，做了降配处理，春节前活动直接被查询宕机。所以现在需要考虑优化方案">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/1.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/2.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/3.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/4.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/5.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/6.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/7.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/8.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/9.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/10.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/11.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/12.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/13.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/14.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/15.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/16.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/17.jpg">
<meta property="og:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/18.jpg">
<meta property="og:updated_time" content="2018-02-06T07:21:13.932Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="虚拟机安装Centos，安装mysql，配置主从（一）">
<meta name="twitter:description" content="前言公司线上使用阿里云的mysql数据库，一直是单点，也是系统中最大的瓶颈。因为开始考虑的是单点，所以第一个负责人将RDS的配置设置的很高，造成了特别大的资源浪费。平时cpu的内存的使用率都特别低。现在的负责人觉得RDS高配置很浪费，做了降配处理，春节前活动直接被查询宕机。所以现在需要考虑优化方案">
<meta name="twitter:image" content="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/1.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://Gengry.github.io/2018/02/05/虚拟机安装Centos，安装mysql，配置主从（一）/"/>





  <title>虚拟机安装Centos，安装mysql，配置主从（一） | 耿瑞阳的博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">耿瑞阳的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://Gengry.github.io/2018/02/05/虚拟机安装Centos，安装mysql，配置主从（一）/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Geng">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="耿瑞阳的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">虚拟机安装Centos，安装mysql，配置主从（一）</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-02-05T13:20:59+08:00">
                2018-02-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/linux/" itemprop="url" rel="index">
                    <span itemprop="name">linux</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/linux/mysql/" itemprop="url" rel="index">
                    <span itemprop="name">mysql</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>公司线上使用阿里云的mysql数据库，一直是单点，也是系统中最大的瓶颈。因为开始考虑的是单点，所以第一个负责人将RDS的配置设置的很高，造成了特别大的资源浪费。平时cpu的内存的使用率都特别低。<br>现在的负责人觉得RDS高配置很浪费，做了降配处理，春节前活动直接被查询宕机。所以现在需要考虑优化方案<br><a id="more"></a></p>
<h2 id="方案一"><a href="#方案一" class="headerlink" title="方案一"></a>方案一</h2><p>直接使用阿里云的RDS配置主从，RDS自动支持读写分离，简单易用，能用钱解决的问题都是小问题，暂定也是使用这个方案。</p>
<h2 id="方案二"><a href="#方案二" class="headerlink" title="方案二"></a>方案二</h2><p>使用阿里云的ECS自己搭建mysql的集群。配置mysql读写分离，高可用，防止单点故障造成直接宕机。<br>虽然定的方案是使用RDS，但是我还是在本地搭建一下这个环境，以备不时之需。  </p>
<h3 id="安装VMware"><a href="#安装VMware" class="headerlink" title="安装VMware"></a>安装VMware</h3><p>此步骤略过。</p>
<h3 id="安装Centos"><a href="#安装Centos" class="headerlink" title="安装Centos"></a>安装Centos</h3><p>下载Centos的ISO包，但是官网的速度简直是巨慢无比无法忍受，可以在中国的镜像站下载。<br>可以从我的博客<a href="/2018/01/29/国内开源镜像站/">国内开源镜像站</a>获取开源镜像站<br>推荐使用<a href="http://mirrors.ustc.edu.cn/" target="_blank" rel="noopener">中国科学技术大学</a>。<br>页面中可以<code>Ctrl+f</code>搜索centos快速定位。在文件目录下找到centos官方推荐使用的最新版本。<a href="http://mirrors.ustc.edu.cn/centos/7.4.1708/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso" target="_blank" rel="noopener">CentOS7</a></p>
<blockquote>
<p>CentOS-7-x86_64-DVD-1708.iso               标准安装版，一般下载这个就可以了<br>CentOS-7-x86_64-NetInstall-1708.iso        网络安装镜像<br>CentOS-7-x86_64-Everything-1708.iso        对完整版安装盘的软件进行补充，集成所有软件。<br>CentOS-7-x86_64-LiveGNOME-1708.iso     GNOME桌面版<br>CentOS-7-x86_64-LiveKDE-1708.iso           KDE桌面版<br>CCentOS-7-x86_64-LiveKDE-1708-livecd.iso            光盘上运行的系统，类拟于winpe   </p>
</blockquote>
<h4 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h4><p><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/1.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/2.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/3.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/4.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/5.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/6.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/7.jpg" alt=""><br>新手最简单安装一路继续，安装成功后登陆。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/8.jpg" alt=""><br>配置网络，在安装完虚拟就后一般会自动生成两个网络适配器，这个可以删除也可以自定义，但是本次我们使用默认生成的<code>VMware Network Adapter VMnet8</code><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/9.jpg" alt=""><br>现在需要将可以上网的网卡的网络共享给虚拟机的网络适配器。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/10.jpg" alt=""><br>现在看VMware Network Adapter VMnet8的属性，可以看到为他生成了ip地址。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/11.jpg" alt=""><br>根据这个信息配置，虚拟机的虚拟网络（编辑-&gt;虚拟网络编辑器）<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/12.jpg" alt="">  </p>
<h4 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h4><p>虚拟机启动默认网络是不自动开启的，编辑网络的配置文件<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/13.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/14.jpg" alt=""><br>重启network服务，已经获取到ip地址，测试实体机可以ping通。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/15.jpg" alt=""><br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/16.jpg" alt=""><br>开启ssh外网连接。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/17.jpg" alt=""><br>重启centos。<br>使用<code>xshell</code>连接。<br><img src="https://raw.githubusercontent.com/Gengry/blogImage/master/20180205/18.jpg" alt="">  </p>
<blockquote>
<p><a href="http://blog.csdn.net/bao19901210/article/details/51917641" target="_blank" rel="noopener">http://blog.csdn.net/bao19901210/article/details/51917641</a><br><a href="http://blog.csdn.net/u012961566/article/details/70237548" target="_blank" rel="noopener">http://blog.csdn.net/u012961566/article/details/70237548</a><br><a href="http://blog.csdn.net/djcode/article/details/78621772" target="_blank" rel="noopener">http://blog.csdn.net/djcode/article/details/78621772</a>  </p>
</blockquote>
<blockquote class="blockquote-center">今天最好的表现，是明天最低的要求。</blockquote>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/mysql/" rel="tag"># mysql</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/02/03/SpringMVC hibernate-validator校验请求参数/" rel="next" title="SpringMVC hibernate-validator校验请求参数">
                <i class="fa fa-chevron-left"></i> SpringMVC hibernate-validator校验请求参数
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/02/06/虚拟机安装Centos，安装mysql，配置主从（二）/" rel="prev" title="虚拟机安装Centos，安装mysql，配置主从（二）">
                虚拟机安装Centos，安装mysql，配置主从（二） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Geng</p>
              <p class="site-description motion-element" itemprop="description">今天最好的表现，是明天最低的要求。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">25</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">13</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#方案一"><span class="nav-number">1.1.</span> <span class="nav-text">方案一</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#方案二"><span class="nav-number">1.2.</span> <span class="nav-text">方案二</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装VMware"><span class="nav-number">1.2.1.</span> <span class="nav-text">安装VMware</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装Centos"><span class="nav-number">1.2.2.</span> <span class="nav-text">安装Centos</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#安装"><span class="nav-number">1.2.2.1.</span> <span class="nav-text">安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#配置"><span class="nav-number">1.2.2.2.</span> <span class="nav-text">配置</span></a></li></ol></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Geng</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
